package com.bw.controller;

import com.bw.bean.AA;
import com.bw.bean.AB;
import com.bw.service.Servicedao;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class Controller {
    @Autowired
    Servicedao dao;


    @RequestMapping("/list")
    public Map getlist()
    {
        double getlist = dao.getlist();
        Map map=new HashMap();
        map.put("status",0);
        map.put("data",getlist);
        return map;
    }

    @RequestMapping("/list2")
    public Map getlist2()
    {
        List<AA> list = dao.getlist2();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("/list3")
    public String getlist3()
    {
        List<AB> list = dao.getlist3();
        ArrayList list2=new ArrayList();
        list2.add("机构");
        list2.add("完运历程");
        list2.add("完运次数");
        list2.add("完运市场");
        list2.add("每次平均时长");
        list2.add("每次平均里程");
        return SugarUtil.getTablePlayData(list2,list);
    }
    @RequestMapping("/list4")
    public Map getlist4()
    {
        List<AA> list = dao.getlist4();
        return SugarUtil.getMapData(list);
    }

    @RequestMapping("/list5")
    public Map getlist5()
    {
        List<AA> list = dao.getlist5();
        return SugarUtil.getPieData(list);
    }
    @RequestMapping("/list6")
    public Map getlist6()
    {
        List<AA> list = dao.getlist6();
        return SugarUtil.getBarData(list);
    }
    @RequestMapping("/list7")
    public Map getlist7()
    {
        List<AA> list = dao.getlist7();
        Map map=new HashMap();
        map.put("status",0);
        map.put("data",list);
        return map;
    }
    @RequestMapping("/list8")
    public Map getlist8()
    {
        double v = dao.getlist8();
        Map map=new HashMap();
        map.put("status",0);
        map.put("data",v);
        return map;

    }

}
